<?php
/**
* （6W8020）非自动转帐交易
* 建行跨行转账 可以转账到信用卡
*/
class Conf6w8020 extends Abccbconf
{
    public function getTransaction()
    {
        $this->_ccbConf->getTransactionHeader();
        $this->_ccbConf->getTransactionSign();
    }

    public function getTransactionBody()
    {
        /**
         * 转出账户号 varChar(32) F 转出账户号为授权账户，转入账户号为签约账户时，为主动收款功能 
         */
        $body['PAY_ACCNO'] = $this->payAccNo;

        /**
         * 转入账户号 varChar(32) 
         */
        $body['RECV_ACCNO'] = $this->parameter['RECV_ACCNO'];

        /**
         * 转入账户名称 varChar(100)
         */
        $body['RECV_ACC_NAME'] = $this->parameter['RECV_ACC_NAME'];

        /**
         *  转入账户开户机构名称 varChar(41) 
         */
        $body['RECV_OPENACC_DEPT'] = $this->parameter['RECV_OPENACC_DEPT'];

        /**
         * 转入账户联行号
         */
        $body['RECV_UBANKNO'] = isset($this->parameter['RECV_UBANKNO']) ? $this->parameter['RECV_UBANKNO'] : '';

        /**
         *  金额 Decimal(16,2) 
         */
        $body['AMOUNT'] = $this->parameter['AMOUNT'];

        /**
         * 币种 Char(2)
         */
        $body['CUR_TYPE'] = $this->curType;

        /**
         *  用途 varChar(38)
         */
        $body['USEOF'] = $this->parameter['USEOF'];

        /**
         *  备注1 varChar(32) 
         */
        $body['REM1'] = isset($this->parameter['REM1']) ? $this->parameter['REM1'] : '';

        /**
         *  备注2 varChar(32) 
         */
        $body['REM2'] = isset($this->parameter['REM2']) ? $this->parameter['REM2'] : '';
        return $body;
    }

    public function validateParameter()
    {
        if ( empty($this->parameter['RECV_ACCNO']) ) {
            throw new Exception("转入账户号有误", 1);
        }

        if ( empty($this->parameter['RECV_ACC_NAME']) ) {
            throw new Exception("请输入转入账户名称", 1);
        }

        if ( empty($this->parameter['RECV_OPENACC_DEPT']) ) {
            throw new Exception("请输入转入账户开户机构名称", 1);
        }

        if ( $this->parameter['AMOUNT'] <= 0 ) {
            throw new Exception("转账金额必须大于0", 1);
        }
        return TRUE;
    }
}